package com.gongj.lifecycle;

import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;

//@Component
public class CustomizeSmartLifecycle2 implements SmartLifecycle {

	private volatile boolean running = false;

	@Override
	public void start() {
		running = true;
		System.out.println("CustomizeSmartLifecycle2 start() =====>");
	}

	@Override
	public void stop() {
		System.out.println("CustomizeSmartLifecycle1 stop() =====>");
		running = false;
	}

	@Override
	public boolean isRunning() {
		System.out.println("CustomizeSmartLifecycle2 isRunning() =====> " + running);
		return running;
	}

	@Override
	public boolean isAutoStartup() {
		return true;
	}

	@Override
	public void stop(Runnable callback) {
		System.out.println("CustomizeSmartLifecycle2 stop(Runnable callback) =====>");
		callback.run();
	}

	@Override
	public int getPhase() {
		return -1;
	}
}
